package org.jetlinks.pro.koudai.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.ezorm.rdb.mapping.annotation.EnumCodec;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;
import org.jetlinks.pro.koudai.enums.ResourceType;

import javax.persistence.Column;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * 实验课程信息
 *
 * @author zhoukun
 * @since 1.3
 */
@Getter
@Setter
@Table(name = "k_resource_library", indexes = {
    @Index(name = "idx_resource_library_id", columnList = "id")
})
public class ResourceLibraryEntity extends GenericEntity<String> {

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "资源名称")
    private String resourceName;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "资源地址")
    private String resourceUrl;

    @Column(length = 64)
    @Schema(description = "资源类型")
    @ColumnType(javaType = String.class)
    @EnumCodec
    private ResourceType resourceType;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "资源归属")
    private String courseId;

    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date createTime;

    @Column
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date updateTime;



}
